﻿using BBCore.Core.Models.Samples;
using BootstrapBlazor.Components;
using FreeSql;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BBCore.Application.Admins
{
    /// <summary>
    /// Table组件OnQueryAsync通用查询方法
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IDataQueryService<T> where T : class
    {
        /// <summary>
        /// 构建分页查询结果
        /// </summary>
        /// <param name="options">查询选项（分页/排序/过滤参数）</param>
        /// <returns></returns>
        Task<QueryData<T>> OnQueryAsync(QueryPageOptions options);

        /// <summary>
        /// 构建分页查询结果
        /// </summary>
        /// <param name="options">查询选项（分页/排序/过滤参数）</param>
        /// <param name="queryBuilder">
        /// [可选] 查询构建委托
        /// <para>示例：q => q.Where(x => x.Id == 123).OrderBy(x => x.CreateTime)</para>
        /// <para>支持方法：</para>
        /// <list type="bullet">
        /// <item><see cref="ISelect{T}.Where(Expression{Func{T, bool}})"/> 条件过滤</item>
        /// <item><see cref="ISelect{T}.OrderBy(Expression{Func{T, object}})"/> 排序</item>
        /// <item><see cref="ISelect{T}.Include(Expression{Func{T, object}})"/> 关联查询</item>
        /// <item>其他FreeSql链式方法</item>
        /// </list>
        /// </param>
        /// <returns>分页查询结果</returns>
        Task<QueryData<T>> OnQueryAsync(QueryPageOptions options, Func<ISelect<T>, ISelect<T>>? queryBuilder);
    }
}
